package com.his.his_system.controller;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.his.his_system.common.util.ResultAdvice;
import com.his.his_system.domain.DzmHisHospital;
import com.his.his_system.domain.DzmHisInspectionfee;
import com.his.his_system.domain.DzmHisMember;
import com.his.his_system.service.DzmHisHospitalService;
import com.his.his_system.service.DzmHisInspectionfeeService;
import com.his.his_system.service.DzmHisMemberService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RequestMapping("/his/sys/insp/")
@RestController
@ResponseBody
public class InspectionfeeController {

    @Autowired
    private DzmHisInspectionfeeService dzmHisInspectionfeeService;

    @Autowired
    private DzmHisMemberService memberService;

    @Autowired
    private DzmHisHospitalService hospitalService;


    @GetMapping("/list")
    public ResultAdvice list(String name, String type, Integer currentpage) {
        if (name == null && type == null) {
            PageHelper.startPage(currentpage, 4);
            List<DzmHisInspectionfee> inspectionfees = dzmHisInspectionfeeService.listAll();
            return ResultAdvice.success(new PageInfo<>(inspectionfees));
        }
        PageHelper.startPage(currentpage, 4);
        List<DzmHisInspectionfee> inspectionfees = dzmHisInspectionfeeService.like(name, type);
        return ResultAdvice.success(new PageInfo<>(inspectionfees));
    }


    @PostMapping("/addOrUpdate")
    public ResultAdvice add(@RequestBody DzmHisInspectionfee dzmHisInspectionfee) {
        return ResultAdvice.success(dzmHisInspectionfeeService.saveOrUpdate(dzmHisInspectionfee));
    }

    @GetMapping("del")
    public ResultAdvice del(Integer id) {
        return ResultAdvice.success(dzmHisInspectionfeeService.removeById(id));
    }

}
